<?php
/**
*
* 功能描述（短信控制器）
*
* @author suoya <jlusuoya@gmail.com>
* @version 1
*/

class CtrlMobile extends CtrlBase
{
	public $paramCheck = array(
		"sendauthcode" => array(
			"mobile" => array("GET", "must", "trim", "mobile"),
			"mobile_auth" => array("SESSION", "", "", ""),
			'opmsg' => array('GET', 'must', 'trim', 'notempty'),
		),
		"checkauthcode" => array(
			"mobile" => array("GET", "must", "trim", "mobile"),
			"authcode" => array("GET", "must", "intval", "positive"),
			"mobile_auth" => array("SESSION", "", "", ""),
		),
	);

	function SendAuthcode()
	{
		$mobile = $this->params['mobile'];
		$obj = $this->GetModel("mobile");
		$auth_obj = $obj->SendAuthcode($mobile, $this->params['mobile_auth'], $this->params['opmsg']);
		if($auth_obj == 0)
			echo 2;
		else
		{
			$_SESSION['mobile_auth'] = $auth_obj;
			echo 1;
		}
		return RT_NONE;
	}

	function CheckAuthcode()
	{
		$obj = $this->GetModel("mobile");
		$auth_obj = $this->params['mobile_auth'];
		if($auth_obj == "")
			echo 2;
		else
		{
			$ret = $obj->CheckAuthcode($this->params['mobile'], $this->params['authcode'], $auth_obj);
			$_SESSION['mobile_auth'] = $auth_obj;	//必须回存
			echo $ret;
		}
		return RT_NONE;
	}
}

